﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace UI.Forms
{
    public partial class CRM_GYS : FormBase1
    {
        public CRM_GYS()
        {
            InitializeComponent();
            this.Load += new EventHandler(CRM_GYS_Load);
        }

        void CRM_GYS_Load(object sender, EventArgs e)
        {
            bind();
        }

        private void btn_new_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            CRM_GYS_N frm = new CRM_GYS_N();
            frm.FatherRefresh = bind;
            frm.Show();
        }
        private void bind()
        {
            gridControl1.DataSource = my.bw.View_Client_lite_List(true, my.ACID);
        }

        private void btn_update_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SVC.client.View_Client_lite c = gridView1.GetRow(gridView1.FocusedRowHandle) as SVC.client.View_Client_lite;
            if (c == null) return;
            CRM_GYS_U frm = new CRM_GYS_U(c.ClientID);
            frm.FatherRefresh = bind;
            frm.Show();
        }

        private void btn_delete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SVC.client.View_Client_lite c = gridView1.GetRow(gridView1.FocusedRowHandle) as SVC.client.View_Client_lite;
            if (c == null) return;
            string r = my.bw.CRM_ClientByClientID_Delete(c.ClientID, my.ACID);
            if (string.IsNullOrEmpty(r))
            {
                bind();
            }
            else
            {
                Comm.ShowErorr(r);
            }
        }

        private void btn_sx_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            bind();
        }
    }
}